package com.groupnections.server.database.user;

import com.groupnections.server.database.problem.ConvertDatabaseToProblem;
import com.groupnections.server.database.solution.ConvertDatabaseToSolution;

public class ConvertDatabaseToUser {

	public static com.groupnections.shared.entities.User getUser(
			User databaseUser) {

		com.groupnections.shared.entities.User user = new com.groupnections.shared.entities.User();

		if (databaseUser.getUserID() != null) {

			user.setUserID(databaseUser.getUserID().getId());
		}

		user.setName(databaseUser.getName());

		user.setContact(databaseUser.getContact());

		if (databaseUser.getGroups() != null) {

			user.setGroups(databaseUser.getGroups().getValue());
		}

		user.setUserProblems(ConvertDatabaseToProblem.getProblems(databaseUser
				.getUserProblems()));

		user.setUserSolutions(ConvertDatabaseToSolution
				.getSolutions(databaseUser.getUserSolutions()));

		return user;
	}
}
